package com.zero;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

/**
 * 启动程序
 * @author 蔡徐坤
 */
@Slf4j
@MapperScan("com.zero.**.mapper")
@SpringBootApplication
public class ZeroApplication {

    @SneakyThrows
    public static void main(String[] args) {
        System.setProperty("spring.devtools.restart.enabled", "false");
        ConfigurableApplicationContext application = SpringApplication.run(ZeroApplication.class, args);
        Environment env = application.getEnvironment();
        log.info("\n" +
                "    ___  ___  ________   ___  _________  ________  ___  _____ ______   _______   ___\n" +
                "   |\\  \\|\\  \\|\\   ___  \\|\\  \\|\\___   ___\\\\   __  \\|\\  \\|\\   _ \\  _   \\|\\  ___ \\ |\\  \\      Application '{}' is running! Access URLs: \n" +
                "   \\ \\  \\ \\  \\ \\  \\\\ \\  \\ \\  \\|___ \\  \\_\\ \\  \\|\\  \\ \\  \\ \\  \\\\\\__\\ \\  \\ \\   __/|\\ \\  \\     Local: http://localhost:{} \n" +
                " __ \\ \\  \\ \\  \\ \\  \\\\ \\  \\ \\  \\   \\ \\  \\ \\ \\   __  \\ \\  \\ \\  \\\\|__| \\  \\ \\  \\_|/_\\ \\  \\    External: http://{}:{} \n" +
                "|\\  \\\\_\\  \\ \\  \\ \\  \\\\ \\  \\ \\  \\   \\ \\  \\ \\ \\  \\ \\  \\ \\  \\ \\  \\    \\ \\  \\ \\  \\_|\\ \\ \\  \\   API文档: http://{}:{}/doc.html \n" +
                "\\ \\________\\ \\__\\ \\__\\\\ \\__\\ \\__\\   \\ \\__\\ \\ \\__\\ \\__\\ \\__\\ \\__\\    \\ \\__\\ \\_______\\ \\__\\\n" +
                " \\|________|\\|__|\\|__| \\|__|\\|__|    \\|__|  \\|__|\\|__|\\|__|\\|__|     \\|__|\\|_______|\\|__|",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"));
    }
}
